/**   
 * Copyright © 2016 公司名. All rights reserved.
 * 
 * @Title: NoticeServiceImpl.java 
 * @Prject: LianniuManager
 * @Package: com.lianniu.mgr.baseService.notice.service.impl
 * @Description: TODO
 * @author: lzz   
 * @date: 2016年8月8日 上午8:50:51 
 * @version: V1.0   
 */
package com.lianniu.web.baseService.notice.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lianniu.web.base.BaseResult;
import com.lianniu.web.baseService.notice.dao.INoticeDao;
import com.lianniu.web.baseService.notice.enums.NoticeStatusEnum;
import com.lianniu.web.baseService.notice.model.NoticeVo;
import com.lianniu.web.baseService.notice.service.INoticeService;
import com.lianniu.web.pagination.PaginationInfo;

/** 
 * @ClassName: NoticeServiceImpl 
 * @Description: TODO
 * @author: lzz
 * @date: 2016年8月8日 上午8:50:51  
 */
@Service("noticeService")
public class NoticeServiceImpl implements INoticeService{
    
    public static final Logger logger = Logger.getLogger(NoticeServiceImpl.class); 
    
    @Resource
    private INoticeDao noticeDao;
    public BaseResult getNoticeList(NoticeVo noticeVo,PaginationInfo paginationInfo){
        logger.info("NoticeServiceImpl getNoticeList begin");
        noticeVo.setPaginationInfo(paginationInfo);
        Map<String, Object> retmap = new HashMap<>();
        List<NoticeVo> list = noticeDao.getNoticeListForPage(noticeVo);
        retmap.put("total", paginationInfo.getTotalRecord());
        retmap.put("curPage", paginationInfo.getCurPage());
        retmap.put("rows", list);
        logger.info("NoticeServiceImpl getNoticeList end");
        return BaseResult.success(retmap);
        
    }
    @Override
    @Transactional
    public BaseResult seeNotice(long noticeId, long userId) {
        logger.info("NoticeServiceImpl seeNotice begin");
        NoticeVo noticeVo = noticeDao.getNoticeById(noticeId);
        logger.info("NoticeServiceImpl seeNotice setStatus begin");
        noticeVo.setStatus(NoticeStatusEnum.LOOKED.getCode());
        noticeDao.editNotice(noticeVo);
        logger.info("NoticeServiceImpl seeNotice setStatus end");
        logger.info("NoticeServiceImpl seeNotice end");
        return BaseResult.success(noticeVo);
    }

}
